package copyengine.network.roomStructure.subMediator
{
	import copyengine.GameFacade;
	import copyengine.network.roomStructure.CENetworkCommandNotification;
	import copyengine.network.roomStructure.data.CENetworkRoomMediatorWhiteBoard;
	import copyengine.network.roomStructure.executeLayer.CENetworkRoomExecuteHandleNotification;
	import copyengine.utils.CENestMediatorBasic;

	public class CENetworkRoomSubMediatorBasic extends CENestMediatorBasic
	{
		protected var whiteBoard:CENetworkRoomMediatorWhiteBoard;

		public function CENetworkRoomSubMediatorBasic(_whiteBoard:CENetworkRoomMediatorWhiteBoard)
		{
			whiteBoard = _whiteBoard;
			super();
		}


		//========================
		//== Send Command&ForwardData
		//========================

		/**
		 * 发送命令到Socket服务器
		 * !!注意 : 若是发送的命令则不会含有forwardData
		 */
		protected final function sendSocketCommand(_command:uint, _commandArg:Object):void
		{
			GameFacade.instance.sendNotification(CENetworkRoomExecuteHandleNotification.RECEIVE_SEND_DATA_SOCKET,
												 {
													 command:_command,
													 commandArg:_commandArg,
													 forwardData:null
												 });
		}

		/**
		 * 发送ForwardData（P2P）
		 * !!注意:发送ForwardData则不会含有CommandArg参数
		 */
		protected final function sendForwardData(_forwardData:Object):void
		{
			//如果当前房间中的玩家数量大于1人及发送，当只有一人时表示只有玩家自己
			if (whiteBoard.roomNeighbourInfoPackageVector.length > 1)
			{
				GameFacade.instance.sendNotification(CENetworkRoomExecuteHandleNotification.RECEIVE_SEND_DATA_MIX,
													 {
														 command:CENetworkCommandNotification.F_RESERVE_COMMAND_TRANSPOND_DATA,
														 commandArg:{uid:whiteBoard.playerUID, roomID:whiteBoard.roomID},
														 forwardData:_forwardData
													 });
			}
		}

	}
}
